﻿Imports System.Data.SqlClient
Public Class ErrorDAO
    Public Shared Function insertarError(ByVal e As Exception)
        Dim cn As SqlConnection = Nothing
        Try
            cn = Conexion.Conectar
            Dim consulta As New SqlClient.SqlCommand
            With consulta
                .CommandText = "usp_error"
                .CommandType = CommandType.StoredProcedure
                With .Parameters
                    .AddWithValue("@ErrorMensaje", e.Message).DbType = DbType.String
                    .AddWithValue("@ErrorFecha", DateTime.Now).DbType = DbType.DateTime
                    .AddWithValue("@ErrorSource", e.Source).DbType = DbType.String
                    .AddWithValue("@ErrorStackTrace", e.StackTrace).DbType = DbType.String
                End With
                .Connection = cn
                .ExecuteNonQuery()
            End With
            Return True
        Catch ex As Exception
            Return False
            'ERROR
        Finally
            Conexion.Desconectar(cn) 'PASAR POR PARAMETRO LA CONEXION
        End Try
    End Function
End Class
